<template>
    <fieldset style="margin-left: 30%; border: 0;">
        <h2>已经完成 <span id="donecount"></span></h2>
        <ul>
            <li v-for="(item, index) in arr" :key="index">
                <input type="checkbox" value="datas" id="datas" name="daat" @click="sendOngoing(index)"  />
                <span>{{ item }}</span>
                <button class="but" @click="deleteThing(index)">删除</button>
            </li>
        </ul>
    </fieldset>
</template>

<script setup>
import { ref } from "vue"
import bus from "../utils/bus"

let arr = ref([])

//接受ongoing传递过来的信息
bus.$on('send', data => {
    // console.log(data)
    arr.value.push(data)
})
function deleteThing(index) {
    arr.value.splice(index, 1)
}
//再传回去
function sendOngoing(index) {
    // 发送到ongoing组件中
    let datas = arr.value.slice(index, index + 1)
    
    bus.$emit('sends', datas[0])
    let daat=datas[0]
    arr.value.splice(index, 1)
}
</script>
<style scoped>
</style>